from enetity_extraction.Information_Extraction import extract_information

def read_article_by_sections(file_path, encoding='utf-8'):
    with open(file_path, 'r', encoding=encoding) as file:
        # 初始化变量以存储当前篇章的文本
        current_section = []
        article_sections = []
        # 逐行读取文件
        for line in file:
            # 使用strip()方法移除行首尾的空白字符，包括换行符
            stripped_line = line.strip()
            # 如果处理后的行不为空，则添加到当前篇章
            if stripped_line:
                current_section.append(stripped_line)
            else:
                # 如果遇到空行，表示当前篇章结束
                if current_section:
                    # 将当前篇章的文本拼接成一个字符串，并添加到篇章列表
                    article_sections = article_sections+current_section
                    # 重置当前篇章的文本存储变量
                    current_section = []
        article_sections = article_sections + current_section
    return article_sections

def get_extraction_results(file_path):
    article_sections = read_article_by_sections(file_path)
    extract_sections = extract_information(article_sections)
    return article_sections,extract_sections

if __name__ == '__main__':

    cases_section=get_extraction_results('/remote-home/cs_tcci_wuyaoyao/20240708_company_project/judicial_document_proofreading/enetity_extraction/0725_test_data/0725_test_data/money.txt')
